﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Battle.Net.Infrastructure;

namespace Battle.Net.Model
{
    [DataContract]
    public class CharacterProgression
    {
        [DataMember(Name = "raids")]
        public List<CharacterRaid> Raids { get; set; }

    }

    [DataContract]
    public class CharacterRaid
    {
        [DataMember(Name = "name")]
        public string Name { get; set; }
        [DataMember(Name = "normal")]
        public int Normal { get; set; }
        [DataMember(Name = "heroic")]
        public int Heroic { get; set; }
        [DataMember(Name = "bosses")]
        public List<Boss> Bosses { get; set; }

        public override string ToString()
        {
            return Name;
        }
    }

    [DataContract]
    public class Boss
    {
        [DataMember(Name = "id")]
        public int Id { get; set; }
        [DataMember(Name = "name")]
        public string Name { get; set; }
        [DataMember(Name = "lfrKills")]
        public int LFRKills { get; set; }
        [DataMember(Name = "lfrTimestamp")]
        private string lfrTimestamp { get; set; }
        [DataMember(Name = "normalKills")]
        public int NormalKills { get; set; }
        [DataMember(Name = "normalTimestamp")]
        private string normalTimestamp { get; set; }
        [DataMember(Name = "heroicKills")]
        public int HeroicKills { get; set; }
        [DataMember(Name = "heroicTimestamp")]
        private string heroicTimestamp { get; set; }

        public Nullable<DateTime> NormalTimeStamp
        {
            get
            {
                if (NormalKills > 0) return normalTimestamp.FromUnixTimestamp();
                return null;
            }
        }

        public Nullable<DateTime> HeroicTimeStamp
        {
            get
            {
                if (HeroicKills > 0) return heroicTimestamp.FromUnixTimestamp();
                return null;
            }
        }

        public Nullable<DateTime> LFRTimeStamp 
        {
            get
            {
                if (LFRKills > 0) return lfrTimestamp.FromUnixTimestamp();
                return null;
            }
        }

        public override string ToString()
        {
            return Name;
        }

    }
}
